<!--#Include File="../conn.asp" -->
<!--#Include File="comm/inc.asp" -->
<%
'====================================================================
'= Team Elite - Elite Article System
'= Copyright (c) 2005 - 2006 Eason Chan All Rights Reserved.
'=-------------------------------------------------------------------
'= 版权协议：
'=	GPL (The GNU GENERAL PUBLIC LICENSE Version 2, June 1991)
'=-------------------------------------------------------------------
'= 文件名称：/Manager/Admin_Member.asp
'= 摘    要：后台-会员管理文件
'=-------------------------------------------------------------------
'= 最后更新：eason007
'= 最后日期：2005-12-21
'====================================================================

Call EA_Manager.Chk_IsMaster

If Not EA_Manager.Chk_Power(Admin_Power,"22") Then 
	ErrMsg=str_Comm_NotAccess
	Call EA_Manager.Error(1)
End If

Dim Atcion
Atcion=Request.QueryString ("atcion")

Select Case LCase(Atcion)
Case "add"
	Call Add
Case "save"
	Call Save
Case "del"
	Call Del
Case "lock"
	Call Locker
Case "unlock"
	Call UnLocker
Case Else
	Call Main
End Select
Call EA_Pub.Close_Obj
Set EA_Pub=Nothing

Sub Main
	Dim Count,PageCount,Page,OutStr,i
	Dim FieldName(1),FieldValue(1)
	Dim WSQL,Temp
	Dim KeyWord,Field,TopicList
	Dim ListBlock,GroupList

	Page=EA_Pub.SafeRequest(3,"page",0,1,0)
	KeyWord=EA_Pub.SafeRequest(1,"keyword",1,"",0)
	Field=EA_Pub.SafeRequest(1,"group",0,0,0)

	Select Case Atcion
	Case "search"
		WSQL="where reg_name like '%"&KeyWord&"%' and user_group="&Field
	End Select
	
	Temp=EA_M_DBO.Get_Group_List()
	If IsArray(Temp) Then
		For i=0 To UBound(Temp,2)
			GroupList = GroupList & "<option value="""&Temp(0,i)&""">"&Temp(1,i)&"</option>"
		Next
	End If
	
	PageContent=Template.LoadTemplate("admin_member_list.htm")

	Template.SetVariable "Language_Comm_ListEmpty",str_Comm_ListEmpty,PageContent
	Template.SetVariable "Language_Comm_Bar_Operation",str_Comm_Bar_Operation,PageContent
	Template.SetVariable "Language_Comm_Edit_Operation",str_Comm_Edit_Operation,PageContent
	Template.SetVariable "Language_Comm_Alert_Del_Operation",str_Comm_Alert_Del_Operation,PageContent
	Template.SetVariable "Language_Comm_Del_Operation",str_Comm_Del_Operation,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Member_Help",str_Member_Help,PageContent

	Template.SetVariable "Language_Member_Account",str_Member_Account,PageContent
	Template.SetVariable "Language_Member_State",str_Member_State,PageContent
	Template.SetVariable "Language_Member_GroupName",str_Member_GroupName,PageContent
	Template.SetVariable "Language_Member_RegDate",str_Member_RegDate,PageContent
	
	Template.SetVariable "Language_QuickSearchUser",str_QuickSearchUser,PageContent
	Template.SetVariable "Language_UserGroup",str_UserGroup,PageContent
	Template.SetVariable "Language_SearchNow",str_SearchNow,PageContent
	
	Template.SetVariable "GroupList",GroupList,PageContent


	ListBlock=Template.GetBlock("list",PageContent)

	SQL="Select Count([Id]) From [NB_User] "&WSQL
	Count=Conn.Execute(SQL)(0)
	If Count>0 Then 
		Template.SetVariable "ListTempty","none",PageContent

		If Rs.State=1 Then Rs.Close
		If iDataBaseType=0 Then
			SQL="Select a.[Id],Reg_Name,b.GroupName,a.Email,a.RegTime,IIF(State=0,'" & str_Comm_State_NoPass & "','" & str_Comm_State_Pass & "') From [NB_User] a Left Join [NB_UserGroup] b On a.User_Group=b.[Id] "&WSQL&" Order By a.[Id] Desc"
		Else
			SQL="Select a.[Id],Reg_Name,b.GroupName,a.Email,a.RegTime,Case State When 0 Then '" & str_Comm_State_NoPass & "' Else '" & str_Comm_State_Pass & "' End From [NB_User] a Left Join [NB_UserGroup] b On a.User_Group=b.[Id] "&WSQL&" Order By a.[Id] Desc"
		End If
		'Response.Write sql
		Rs.Open SQL,Conn,1,1
		If Not rs.eof And Not rs.bof Then 
			Rs.AbsolutePosition=Rs.AbsolutePosition+((Abs(Page)-1)*15)
			TopicList=Rs.GetRows(15)
		End If
		Rs.Close
	
	    For i=0 To Ubound(TopicList,2)
			Temp=ListBlock
  
			Template.SetVariable "Member_ID",TopicList(0,i),Temp
			Template.SetVariable "Member_Account",TopicList(1,i),Temp
			Template.SetVariable "Member_GroupName",TopicList(2,i),Temp
			Template.SetVariable "Member_Email",TopicList(3,i),Temp
			Template.SetVariable "Member_RegDate",TopicList(4,i),Temp
			Template.SetVariable "Member_State",TopicList(5,i),Temp
			
			Template.SetBlock "list",Temp,PageContent
		Next

		Template.SetVariable "PageListNav",EA_Manager.PageList(15,Count,Page,FieldName,FieldValue),PageContent
	End If
	Template.CloseBlock "list",PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Add
	Dim PostId
	Dim RegName,Sex,Email,RegTime,Login,Name,BirtDay
	Dim UserGroup,State
	Dim Temp,i,GroupList
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)

	Temp=EA_M_DBO.Get_Member_Info(PostId)
	If IsArray(Temp) Then 
		RegName=Temp(1,0)
		Sex=Temp(2,0)
		Email=Temp(3,0)
		RegTime=Temp(4,0)
		Login=Temp(5,0)
		Name=Temp(6,0)
		BirtDay=Temp(7,0)
		UserGroup=Temp(8,0)
		State=Temp(9,0)
	End If
	
	Temp=EA_M_DBO.Get_Group_List()
	If IsArray(Temp) Then
		For i=0 To UBound(Temp,2)
			GroupList = GroupList & "<option value="""&Temp(0,i)&""""
			If Cint(UserGroup)=Cint(Temp(0,i)) Then GroupList = GroupList & " selected"
			GroupList = GroupList & ">"&Temp(1,i)&"</option>"
		Next
	End If

	PageContent=Template.LoadTemplate("admin_member_option.htm")

	Template.SetVariable "Language_Comm_Save_Button",str_Comm_Save_Button,PageContent
	Template.SetVariable "Language_Comm_Reset_Button",str_Comm_Reset_Button,PageContent
	Template.SetVariable "Language_Comm_Yes",str_Comm_Yes,PageContent
	Template.SetVariable "Language_Comm_No",str_Comm_No,PageContent
	Template.SetVariable "Language_Comm_Select",str_Comm_Select,PageContent

	Template.SetVariable "Language_OperationNotice",str_OperationNotice,PageContent
	Template.SetVariable "Language_Member_Help",str_Member_Help,PageContent
	Template.SetVariable "Language_Member_MemberInfo",str_Member_MemberInfo,PageContent

	Template.SetVariable "Language_Member_Account",str_Member_Account,PageContent
	Template.SetVariable "Language_Member_State",str_Member_State,PageContent
	Template.SetVariable "Language_Member_Sex",str_Member_Sex,PageContent
	Template.SetVariable "Language_Member_NickName",str_Member_NickName,PageContent
	Template.SetVariable "Language_Member_LoginTotal",str_Member_LoginTotal,PageContent
	Template.SetVariable "Language_Member_BirtDay",str_Member_BirtDay,PageContent
	Template.SetVariable "Language_Member_GroupName",str_Member_GroupName,PageContent
	Template.SetVariable "Language_Member_RegDate",str_Member_RegDate,PageContent
	Template.SetVariable "Language_Member_IsLogin",str_Member_IsLogin,PageContent

	Template.SetVariable "MemberID",PostId,PageContent
	Template.SetVariable "Account",RegName,PageContent
	If Sex Then
		Template.SetVariable "Sex",str_Member_Sex_Man,PageContent
	Else
		Template.SetVariable "Sex",str_Member_Sex_Woman,PageContent
	End If
	Template.SetVariable "NickName",Name,PageContent
	Template.SetVariable "Email",Email,PageContent
	Template.SetVariable "LoginTotal",Login,PageContent
	Template.SetVariable "RegTime",RegTime,PageContent
	Template.SetVariable "BirtDay",BirtDay,PageContent
	Template.SetVariable "GroupList",GroupList,PageContent
	Template.SetVariable "IsLogin_" & State," checked",PageContent
	

	Template.BaseReplace PageContent
	Template.OutStr PageContent
End Sub

Sub Save
	Call EA_Pub.Chk_Post
	
	Dim UserGroup,State
	Dim PostId
	
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	UserGroup=EA_Pub.SafeRequest(2,"usergroup",0,0,0)
	State=EA_Pub.SafeRequest(2,"state",0,0,0)
		
	If PostId<>0 And UserGroup<>0 Then
		SQL="UPDATE NB_User SET User_Group = "&UserGroup&", State = "&State
		SQL=SQL&" WHERE Id="&PostId
		Conn.Execute(SQL)
	End If
	
	Set Rs=Nothing
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect "admin_member.asp"
End Sub

Sub Del
	Call EA_Pub.Chk_Post
	
	Dim PostId
	PostId=EA_Pub.SafeRequest(3,"postid",0,0,0)
	
	EA_M_DBO.Set_Member_Delete PostId
	
	Call EA_Pub.Close_Obj
	Set EA_Pub=Nothing
	
	Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
%>